<?php

/**
 * Giftbox form.
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
 */
class GiftboxForm extends BaseGiftboxForm
{
  public function getChoisePub()
  {
      if(sfContext::getInstance()->getUser()->issuperAdmin())
      return array('1' => 'новый', '2' => 'на утверждении', '3' => 'утвержден');

      if(sfContext::getInstance()->getUser()->hasCredential('partner'))
      return array('1' => 'новый', '2' => 'на утверждении' );
  }


  public function configure()
  {
  	
  	 unset(
     
      $this['created_at'],
      $this['from_id'],
      $this['to_id'],
      $this['gift_id']
    );
    
        $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'pub'        => new sfWidgetFormChoice ( array ('choices' => $this->getChoisePub() )),
      'photo'      => new sfWidgetFormInputFile(),
      ));

            $this->validatorSchema ['photo'] = new sfValidatorFile ( array ('required' => false,
		'path' => sfConfig::get ( 'sf_web_dir' ) . '/uploads/gift/send',
		'mime_types' => 'web_images', 'max_size' => 500000,
                'validated_file_class' => 'sfGiftSendValidatedFile' ) );

    $this->widgetSchema->setNameFormat('gift[%s]');


  	
  }
}
